
import _ from 'lodash'

/**
* 文件打包映射
*/
export default class FileMap {

  constructor(option: any) {

  }

  /**
   * 最初的文件位置
   */
  file = '';

  /**
   * 打包之后在包中的位置
   */
  zip = '';

}

declare namespace Config {

  type BuildCmd = string[] | { [project: string]: string[] };

  type Files = { [project: string]: FileMap | string[] };

  type Deploy = { env: string, user: string, middleServer: string, targetServer: [string], buildCmd?: [string] };

}

export class Config {

  constructor(config: Config) {
    console.log(JSON.stringify(config));
    _.assign(this, config);
  }

  project = '';
  outDir = 'build';
  tmpDir = '';
  deployDir = '';
  htmlDeployDir = '';
  buildCmd: Config.BuildCmd = [];
  //   version: {
  //     file: 'frame-web/src/main/resources/project.properties',
  //     content: function (ver) {
  //       return `# 这个文件由ci工具自动生成
  // # 请不要随意修改

  // project.version=${ver}
  // `;
  //     }
  //   },
  // files = {
  //   'frame-service': ['node_modules/ejs']
  // }

  files: Config.Files = {};

  deploys: Config.Deploy[] = [];
  //  = [{
  //   env: 'prod',
  //   user: 'root',
  //   middleServer: '192.168.1.22',
  //   targetServer: ['192.168.1.25'],
  //   // buildCmd:['npm run build'],
  // }, {
  //   env: 'test',
  //   user: 'root',
  //   middleServer: '192.168.1.22',
  //   targetServer: ['192.168.1.25'],
  //   // buildCmd:['npm run build'],
  // }]

}

export class ConfigWrapper extends Config{
  
  constructor(config:Config){
    super(config);
  }

  getBuildCmd(projects: string[]): string[] {
    
    return ['echo 1','echo 2']

  }



  


}